- /* sdominus.cpp by K.Tsuru */
- // function ID = 331 DRADIX
- /***************************************
- SDouble class
- It provides the subtraction operator-().
- It returns "m-n".
- ****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble operator-(const SDouble& m, const SDouble& n){
- if((m.Type() != m.REAL)||(n.Type() != n.REAL)) m.SetError(m.RADIX_ERR, "SD -", 331);
- int sgn = m.Sign(331)*n.Sign(331), c;
- if( sgn == 0 ){ //m and/or n =0
- if( m.Sign() == 0 ) return -n;
- else return m;
- } else if(sgn < 0){ //different sign m - n = m + (-n)
- return DDAdd(m, -n); //The sign is the same that of m, set in DDAdd().
- } else { //same sign
- c = DDCompare(m, n);
- if(c > 0) return DDSub(m, n); //|m|>|n|, The sign is same as that of m,set in DDSub().
- else if(c) return -DDSub(n, m); //|m|<|n|, m-n=-(n-m)
- else return 0.0; // c = 0 : m = n result = 0
- }
- }
sdominus.cpp : last modifiled at 2015/11/25 20:18:29(936 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).